Name layers of drawing in the Room Editor tab - ground, things, sky - and a whole layer is always drawn over the one before it. Inside a layer, things sort by depth or by how far down the screen they are.
Without depth groups, every picture in the game is sorted by one number, its depth. That works, but it is one big pile: the floor decorations, the characters, the clouds and the HUD frame all fight over the same numbers.
A depth group is a named layer of drawing. You make a few of them, put them in order, and say which group each object lives in. A whole group is always drawn over the groups before it, whatever the depth of anything inside either one.
| Group (back to front) | What lives in it |
|---|---|
ground | puddles, shadows, floor decorations |
things | the player, enemies, crates, trees |
sky | clouds, a bird flying over everything |
A shadow in ground can never be drawn over the player in things, even if you give the shadow a depth that looks "closer". The group decides first.
A project with no groups is drawn exactly as it always was. Groups are something you add when you want them.
Open the Room Editor tab. The Depth groups section in the right-hand panel lists the groups, back first.
Each group has three choices:
| Choice | What it does |
|---|---|
| Sort by y | Inside this group, things lower on the screen are drawn over things higher up. This is the look of a top-down game: walk behind a tree and it covers you, walk in front and you cover it. With it off, things are ordered by their depth. |
| Steps of | With Sort by y: the height, in pixels, of the steps the y position is rounded to. Two things in the same step keep the same order, so they do not flicker over each other when they stand side by side. 16 is a good start. |
| Behind the background | The whole group is drawn behind the room's picture - its tiles. Use it for something seen through a gap in the floor, such as water under a bridge. |
A project can have up to 16 groups.
There are three places, from the whole object down to one copy:
draw_sprite, draw_text and the other draw_ calls keeps ordering by the depth of the object that draws it, as before.